#include "DustObject.h"

int DustObject::dust_name = 0;
bool DustObject::compiled = false;

DustObject::DustObject()
{
}

DustObject::~DustObject()
{
}




void DustObject::LoadLists()
{
 dust_name = glGenLists(1); 


glNewList(dust_name,GL_COMPILE);
           
        //glBlendFunc(GL_SRC_ALPHA,GL_ONE);       
        glEnable(GL_BLEND);         
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D,state->th->texNames[TEX_BULLET]);
        glRotatef(180,0,0,1);
        
        glBegin(GL_QUADS);
              glTexCoord2f(0.0f, 1.0f);   glVertex3f(-2,-2,0);
              glTexCoord2f(0.0f, 0.0f);   glVertex3f(-2,2,0);
              glTexCoord2f(1.0f, 0.0f);   glVertex3f(2,2,0 );
              glTexCoord2f(1.0f, 1.0f);   glVertex3f(2,-2,0 );
        glEnd();
        
        glDisable(GL_TEXTURE_2D);
        glDisable(GL_BLEND);  
        
glEndList();
compiled = true;
}

void DustObject::DoIdle()
{
  scale-= 0.08;  
  if (scale < 0.1) visible  = false;
}

void DustObject::Init()
{
    scale = 1;
    visible = true;
    if (!compiled) LoadLists();
}




void DustObject::Draw()
{
  
 glPushMatrix();
        glColor4f(0.50f, 1.0f, 1.0f, scale);  
        glTranslatef(pos.x,pos.y-5,pos.z);
        glRotatef(-state->cam_angY,0,1,0);
        glScalef(scale,5*scale,1);
        glCallList(dust_name);
glPopMatrix();

}
